﻿// ==UserScript==
// @name   EasyvideoSwfaccAntiadsblack
// @namespace   QingTian
// @author   晴天小毛豆
// @description   视频swf硬件加速、去除ad广告反黑、标签tab全屏支持用户脚本
// @version   3.2.6Nightly+2015.08.12pre
// @downloadURL   https://qtxmd.googlecode.com/svn/xmlscript/EasyvideoSwfaccAntiadsblack.user.js
// @updateURL   https://qtxmd.googlecode.com/svn/xmlscript/EasyvideoSwfaccAntiadsblack.user.js
// @icon   https://code.google.com/p/qtxmd/logo?cct=1391043764
// @charset   utf-8
// @include   //
// @grant   GM_xmlhttpRequest
// @run-at   document-idle
// @视频反跨域,需使用代理;方式:代理服务flvr.pandora.tv端口80;通用规则^https?:\/\/[^\/]+\.(youku|tudou|ku6|i?qiyi|letv|pptv|pps|sina|sohu)[^.]*?\.(com(\.cn)?|tv)\/crossdomain\.xml
// @优酷源修复,1`需使用代理;方式:代理服务119.167.145.81端口80;代理规则f.youku.com 或 2`本地hosts文件添加101.227.10.81 f.youku.com
// ==/UserScript==

// -NoAdsPlayer- //
(function() {
    Function.prototype.bind = function() {
        var fn = this, args = Array.prototype.slice.call(arguments), obj = args.shift();
        return function() {
            return fn.apply(obj, args.concat(Array.prototype.slice.call(arguments)));
        }
    };
    function EasyvideoSwfaccAntiadsblack() {};
    EasyvideoSwfaccAntiadsblack.prototype = {
        _players: null,
        _rules: null,
        _done: null,
        get players() {
            if(!this._players) {
                this._players = {
                    'youku': 'https://qtxmd.googlecode.com/svn/swfplayer/loader_yk.swf',
                    'ku6': 'https://qtxmd.googlecode.com/svn/swfplayer/ku6.swf',
                    'ku6_out': 'https://qtxmd.googlecode.com/svn/swfplayer/ku6_out.swf',
                    'letv': 'https://qtxmd.googlecode.com/svn/swfplayer/letv.swf',
                    'letvsdk': 'https://qtxmd.googlecode.com/svn/swfplayer/letvsdk.swf',
                    'letv_live': 'https://qtxmd.googlecode.com/svn/swfplayer/letv_live.swf',
                    'pps_flv': 'https://qtxmd.googlecode.com/svn/swfplayer/flvplay_s.swf',
                    'pps': 'https://qtxmd.googlecode.com/svn/swfplayer/pps.swf',
                    'pps_out': 'https://qtxmd.googlecode.com/svn/swfplayer/pps_out.swf',
                    'sohu': 'https://qtxmd.googlecode.com/svn/swfplayer/sohu.swf',
                    'sohu_live': 'https://qtxmd.googlecode.com/svn/swfplayer/sohu_live.swf',
                    'KKPlayer': 'http://js.kankan.xunlei.com/player/mp4/KKPlayer2.0.swf'
                };
            }
            return this._players;
        },
        get rules() {
            if(!this._rules) {
                this._rules = {
                    'youku_youku': {
                        'find': /^https?:\/\/static\.youku\.com(\/v[\d\.]+)?\/v\/swf\/loaders?\.swf/i,
                        'replace': this.players['youku']
                    },
                    'youku_player': {
                        'find': /^https?:\/\/static\.youku\.com(\/v[\d\.]+)?\/v\/swf\/q?player[^\.]*\.swf(\?.*)?/i,
                        'replace': this.players['youku'] + '$2'
                    },
                    'youku_out': {
                        'find': /^https?:\/\/player\.youku\.com\/player\.php\/.*sid\/([\w=]+).*(\/v)?\.swf.*/i,
                        'replace': this.players['youku'] + '?showAd=0&VideoIDS=$1'
                    },
                    'youku_out_par': {
                        'find': /^https?:\/\/player\.youku\.com\/player\.php\/sid\/.*\/partnerid\/.*(\/v)?\.swf/i,
                        'replace': this.players['youku']
                    },
                    'ku6_ku6': {
                        'find': /^https?:\/\/player\.ku6cdn\.com\/default\/.*\/\d+\/player[^\.]*\.swf/i,
                        'replace': this.players['ku6']
                    },
                    'ku6_loader': {
                        'find': /^https?:\/\/player\.ku6cdn\.com\/default\/loaders?\/.*(\/v)?\.swf/i,
                        'replace': this.players['ku6']
                    },
                    'ku6_pV': {
                        'find': /^https?:\/\/(img[\d].*|player)\.ku6(cdn)?\.(cn|com)\/(default|player)\/.*\/pV([\d].*[^.]*?)\.swf(\?.*)?/i,
                        'replace': this.players['ku6_out'] + '$6'
                    },
                    'ku6_out': {
                        'find': /^https?:\/\/player\.ku6\.com\/(inside|refer)\/([^\/]+)\/v\.swf.*/i,
                        'replace': this.players['ku6_out'] + '?vid=$2'
                    },
                    'letv_pccs': {
                        'find': /^https?:\/\/.*letv[\w]*\.com\/.*\/newplayer\/.*Player[^\.]*\.swf(\?[^\/]+)&pccsUrl=https?:\/\/(www\.)?letv\.com\/.*\/pccs_.*.xml([^\/]+)/i,
                        'replace': this.players['letv'] + '$1' + '$3'
                    },
                    'letv_letv': {
                        'find': /^https?:\/\/.*letv[\w]*\.com\/.*\/(?!(Live|seed|Disk))(((C|S)[\w]{2,3})?(?!Live)[\w]{4}|swf)Player[^\.]*\.swf/i,
                        'replace': this.players['letv']
                    },
                    'letv_barrage': {
                        'find': /^https?:\/\/.*letv[\w]*\.com\/.*\/(acfunletv|letv-wrapper|letvbili|lbplayer)[^\.]*\.swf/i,
                        'replace': this.players['letv']
                    },
                    'letv_player': {
                        'find': /^https?:\/\/.*letv[\w]*\.com\/[^\.]*\/.*player\/(LetvPlayer|swfPlayer)[^\.]*\.swf/i,
                        'replace': this.players['letv']
                    },
                    'letv_V3LP': {
                        'find': /^https?:\/\/player\.letvcdn\.com\/p\/.*\/newplayer\/V([\d]_)?LetvPlayer\.swf/i,
                        'replace': this.players['letv']
                    },
                    'letv_SDK': {
                        'find': /^https?:\/\/player\.letvcdn\.com\/p\/.*\/newplayer\/SDK([\d]_)?LetvPlayer\.swf/i,
                        'replace': this.players['letv']
                    },
                    'letv_vid_1': {
                        'find': /^https?:\/\/.*letv[\w]*\.com\/.*player[^\.]*\.swf\/type.*\/vid=(\d+).*/i,
                        'replace': this.players['letv'] + '?vid=$1'
                    },
                    'letv_vid_2': {
                        'find': /^https?:\/\/.*letv[\w]*\.com\/.*player[^\.]*\.swf\?.*type.*(vid|id)=(\d+).*/i,
                        'replace': this.players['letv'] + '?vid=$2'
                    },
                    'letv_out': {
                        'find': /^https?:\/\/.*letv[\w]*\.com\/player\/swfplayer\.swf(\?.*)?/i,
                        'replace': this.players['letv'] + '$1'
                    },
                    'letv_out_player': {
                        'find': /^https?:\/\/(www\.)?letv\.com\/player\/[^\.]*?x(\d+)\.swf/i,
                        'replace': this.players['letv'] + '?vid=$2'
                    },
                    'letv_yuntv': {
                        'find': /^https?:\/\/yuntv\.letv\.com\/bcloud\.swf|^https?:\/\/.*letv[\w]*\.com\/p\/.*\/newplayer\/bcloud\.swf/i,
                        'replace': this.players['letvsdk']
                    },
                    'letv_1': {
                        'find': /^https?:\/\/.*letv[\w]*\.com\/.*player[^\.]*\.swf\?v_list=[^\.]*/i,
                        'replace': this.players['letv']
                    },
                    'letv_2': {
                        'find': /^https?:\/\/.*letv[\w]*\.com\/.*\/v_list=[^\.]*\/.*\.swf/i,
                        'replace': this.players['letv']
                    },
                    'letv_3': {
                        'find': /^https?:\/\/player\.hz\.letv\.com\/hzplayer\.swf(\/open|\/.*v_list=[^\.]*)?/i,
                        'replace': this.players['letv']
                    },
                    'letv_live': {
                        'find': /^https?:\/\/player\.hz\.letv\.com\/live\.swf(\/open|\/.*v_list=[^\.]*)?|^https?:\/\/.*letv[\w]*\.com\/.*\/[\w]LivePlayer[^\.]*\.swf/i,
                        'replace': this.players['letv_live']
                    },
                    'pps_iqiyi_flv': {
                        'find': /^https?:\/\/(www\.)?i?qiyi\.com\/player\/.*\/pps_flvplay_s\.swf\?.*v=(\d+)/i,
                        'replace': this.players['pps_flv'] + '?v=$2' + '&autoplay=true'
                    },
                    'pps_iqiyi': {
                        'find': /^https?:\/\/(www\.)?i?qiyi\.com\/player\/cupid\/common\/pps_flvplay_s\.swf/i,
                        'replace': this.players['pps']
                    },
                    'pps_iqiyi_out_sid': {
                        'find': /^https?:\/\/(www\.)?i?qiyi\.com\/player\/.*\/pps_fplayer\.swf\?.*sid=([\w]{6})([^\/]+)?/i,
                        'replace': this.players['pps_flv'] + '?url_key=$2'
                    },
                    'pps_iqiyi_out': {
                        'find': /^https?:\/\/(www\.)?i?qiyi\.com\/player\/cupid\/common\/pps_fplayer\.swf/i,
                        'replace': this.players['pps_out']
                    },
                    'pps': {
                        'find': /^https?:\/\/player\.pps\.tv\/static\/vs\/v.*\/v\/swf\/flvplay_s\.swf/i,
                        'replace': this.players['pps']
                    },
                    'pps_out_sid': {
                        'find': /^https?:\/\/player\.pps\.tv\/.*\/swf\/fplayer\.swf\?.*sid=([\w]{6})([^\/]+)?/i,
                        'replace': this.players['pps_flv'] + '?url_key=$1'
                    },
                    'pps_out': {
                        'find': /^https?:\/\/player\.pps\.tv\/static\/v.*\/v\/swf\/fplayer\.swf/i,
                        'replace': this.players['pps_out']
                    },
                    'pps_sid': {
                        'find': /^https?:\/\/player\.pps\.tv\/player\/sid\/([\w]{6})([^\/]+)?\/v\.swf/i,
                        'replace': this.players['pps_flv'] + '?url_key=$1'
                    },
                    'sohu_main': {
                        'find': /^https?:\/\/tv\.sohu\.com\/upload\/swf(\/p2p(\/yc)?)?\/(sv)?\d+\/Main[^.]*?\.swf/i,
                        'replace': this.players['sohu']
                    },
                    'sohu_playershell': {
                        'find': /^https?:\/\/tv\.sohu\.com\/upload\/swf(\/p2p(\/yc)?)?\/(sv)?\d+\/PlayerShell[^.]*?\.swf/i,
                        'replace': this.players['sohu']
                    },
                    'sohu_webtest': {
                        'find': /^https?:\/\/(220\.181\.90\.161|61\.135\.176\.223:8080)\/((webplayer|testplayer)|(web|test)\/player)\/(Main|PlayerShell)[^.]*?\.swf/i,
                        'replace': this.players['sohu']
                    },
                    'sohu_live': {
                        'find': /^https?:\/\/tv\.sohu\.com\/upload\/swf\/live\/\d+\/(Main|PlayerShell)[^.]*?\.swf/i,
                        'replace': this.players['sohu_live']
                    },
                    'sohu_out_1': {
                        'find': /^https?:\/\/share\.vrs\.sohu\.com\/.*\/v\.swf.*(&id=\d+)/i,
                        'replace': this.players['sohu'] + '?vid=$1'
                    },
                    'sohu_out_2': {
                        'find': /^https?:\/\/share\.vrs\.sohu\.com\/(\d+)\/v\.swf/i,
                        'replace': this.players['sohu'] + '?vid=$1'
                    },
                    'sohu_out_3': {
                        'find': /^https?:\/\/share\.vrs\.sohu\.com\/share\/play\/space\/\d+\/(\d+)\/.*\/v\.swf/i,
                        'replace': this.players['sohu'] + '?vid=&id=$1'
                    },
                    'KKPlayer_to_HD': {
                        'find': /^https?:\/\/js\.kankan\.xunlei\.com\/player\/mp4\/KKPlayer2\.(?!0)[\d]\.swf/i,
                        'replace': this.players['KKPlayer']
                    }
                }
            }
            return this._rules;
        },
        get done() {
            if(!this._done) {
                this._done = new Array();
            }
            return this._done;
        },
        initPreHandlers: function() {
            this.rules['sohu_main']['preHandle'] = function(elem, find, replace, player) {
                if(document.location.host.match(/live.tv.sohu.com/)) {
                    replace = this.players['sohu_live'];
                }
                this.reallyReplace.bind(this, elem, find, replace)();
            }
            this.rules['sohu_webtest']['preHandle'] = function(elem, find, replace, player) {
                if(document.location.host.match(/live.tv.sohu.com/)) {
                    replace = this.players['sohu_live'];
                }
                this.reallyReplace.bind(this, elem, find, replace)();
            }
        },
        addAnimations: function() {
            var style = document.createElement('style');
            style.type = 'text/css';
            style.innerHTML = 'object,embed{\
-webkit-animation-duration:.001s;-webkit-animation-name:playerInserted;\
-ms-animation-duration:.001s;-ms-animation-name:playerInserted;\
-o-animation-duration:.001s;-o-animation-name:playerInserted;\
animation-duration:.001s;animation-name:playerInserted;}\
@-webkit-keyframes playerInserted{from{opacity:0.99;}to{opacity:1;}}\
@-ms-keyframes playerInserted{from{opacity:0.99;}to{opacity:1;}}\
@-o-keyframes playerInserted{from{opacity:0.99;}to{opacity:1;}}\
@keyframes playerInserted{from{opacity:0.99;}to{opacity:1;}}';
            document.getElementsByTagName('head')[0].appendChild(style);
        },
        animationsHandler: function(e) {
            if(e.animationName === 'playerInserted') {
                this.replace(e.target);
            }
        },
        replace: function(elem) {
            if(this.done.indexOf(elem) != -1) return;
            this.done.push(elem);
            var player = elem.data || elem.src;
            if(!player) return;
            var i, find, replace, isReplacing = false;
            for(i in this.rules) {
                find = this.rules[i]['find'];
                if(find.test(player)) {
                    replace = this.rules[i]['replace'];
                    if('function' === typeof this.rules[i]['preHandle']) {
                        isReplacing = true;
                        this.rules[i]['preHandle'].bind(this, elem, find, replace, player)();
                    }
                    if(!isReplacing) {
                        this.reallyReplace.bind(this, elem, find, replace)();
                    }
                    break;
                }
            }
        },
        reallyReplace: function(elem, find, replace) {
            elem.data && (elem.data = elem.data.replace(find, replace)) || elem.src && ((elem.src = elem.src.replace(find, replace)) && (elem.style.display = 'block'));
            this.reloadPlugin(elem);
        },
        reloadPlugin: function(elem) {
            var nextSibling = elem.nextSibling;
            var parentNode = elem.parentNode;
            parentNode.removeChild(elem);
            var newElem = elem.cloneNode(true);
            this.done.push(newElem);
            if(nextSibling) {
                parentNode.insertBefore(newElem, nextSibling);
            } else {
                parentNode.appendChild(newElem);
            }
        },
        init: function() {
            this.initPreHandlers();
            var handler = this.animationsHandler.bind(this);
            document.body.addEventListener('webkitAnimationStart', handler, false);
            document.body.addEventListener('msAnimationStart', handler, false);
            document.body.addEventListener('oAnimationStart', handler, false);
            document.body.addEventListener('animationstart', handler, false);
            this.addAnimations();
        }
    };
    new EasyvideoSwfaccAntiadsblack().init();
})();
// -SwfAccFlashPlsyer- //
var wmode_value = 'direct';
var run_time_max = 100;
var toggle = function (o) {
  if (o) {
    o.setAttribute('fa-sign', 1);
    var display = o.style.display;
    o.style.display = 'none';
    setTimeout(function () {
      o.style.display = 'inline';
      console.log(o);
    }, 0);
  }
};
var run_time = 1;
var find_wmode = function (t) {
  for (var k in t) {
    if (t.name == 'wmode' || t.name == 'wMode') {
      return t;
    }
  }
  return null;
};
var interval = setInterval(function () {
  console.log('run_time', run_time, location);
  if (run_time == run_time_max) {
    clearInterval(interval);
  }
  run_time = run_time + 1;
  var embeds = document.getElementsByTagName('embed');
  if (embeds.length > 0) {
    for (var i = 0; i < embeds.length; i++) {
      if (embeds[i].getAttribute('fa-sign')) {
        continue;
      } 
      else {
        embeds[i].setAttribute('wmode', wmode_value);
        toggle(embeds[i]);
      }
    }
  }
  var objects = document.getElementsByTagName('object');
  if (objects.length > 0) {
    for (var j = 0; j < objects.length; j++) {
      if (objects[j].getAttribute('fa-sign')) {
        continue;
      }
      else{
        var find_wmode = function(t){
          for(var k=0;k<t.length;k++){
            if(t[k].name == "wmode" || t[k].name == "wMode"){
              return t[k];
            }
          }
          return null;
        };
        var d = find_wmode(objects[j].childNodes);
        if (d) {
          d.value = wmode_value;
        }
        else {
          var e = document.createElement('param');
          e.name = 'wmode';
          e.value = wmode_value;
          objects[j].appendChild(e);
        }
        toggle(objects[j]);
      }
    }
  }
}, 500);
// -FlashSwfOnFullTab- //
(function() {
	var parentArray = new Array(),
		player = null,
		fullStatus = false,
		backStyle = new Array(),
		childStyle = new Array(),
		playerStyle, parent, type, iframe;
	function init() {
		createButton();
		window.addEventListener("keydown", function(e) {
			if (e.ctrlKey && e.keyCode == 13 || e.altKey && e.keyCode == 13) {
				playerControl();
			}
		}, false);
		console.log('EasyvideoSwfaccAntiadsblack 初始化');
	}
	function createButton() {
		var leftButton = document.createElement('span');
		leftButton.id = 'leftFullStackButton';
		leftButton.onclick = function() {
			playerControl();
		};
		document.body.appendChild(leftButton);
		addStyle('#leftFullStackButton{position:fixed;width:1px;height:100%;top:0;left:0;z-index:2147483646;}');
		var rightButton = document.createElement('span');
		rightButton.id = 'rightFullStackButton';
		rightButton.onclick = function() {
			playerControl();
		};
		document.body.appendChild(rightButton);
		addStyle('#rightFullStackButton{position:fixed;width:1px;height:100%;top:0;right:0;z-index:2147483646;}');
	}
	function addStyle(css) {
		var style = document.createElement('style');
		style.type = 'text/css';
		var node = document.createTextNode(css);
		style.appendChild(node);
		document.head.appendChild(style);
	}
	function playerControl() {
		if (!player) {
			checkPlayer();
			fullWin();
		} else {
			if (!fullStatus) {
				switch (type) {
					case 'object':
						var objectArray = parent.getElementsByTagName('object');
						checkObject(objectArray);
						break;
					case 'embed':
						var embedArray = parent.getElementsByTagName('embed');
						checkEmbed(embedArray);
						break;
					case 'html5':
						var html5Array = parent.getElementsByTagName('html5');
						checkHtml5(html5Array);
						break;
					case 'innerIframe':
						var innerIframeArray = parent.getElementsByTagName('innerIframe');
						checkInnerIframe(innerIframeArray);
						break;
					case 'iframe':
						var iframeArray = parent.getElementsByTagName('iframe');
						checkIframe(iframeArray);
						break;
				}
				fullWin();
			} else {
				smallWin();
			}
		}
	}
	function checkPlayer() {
		var objectArray = document.getElementsByTagName('object');
		console.log('object数量' + objectArray.length);
		checkObject(objectArray);
		if (!player) {
			console.log('未找到object播放器');
			var embedArray = document.getElementsByTagName('embed');
			console.log('embed数量' + embedArray.length);
			checkEmbed(embedArray);
		}
		if (!player) {
			console.log('未找到embed播放器');
			var html5Array = document.getElementsByTagName('video');
			console.log('html5视频数量' + html5Array.length);
			checkHtml5(html5Array);
		}
		if (!player) {
			console.log('未找到html5播放器');
			var iframeArray = document.getElementsByTagName('iframe');
			console.log('iframe数量' + iframeArray.length);
			checkIframe(iframeArray);
		}
		if (!player) {
			console.log('未找到iframe引用的播放器');
			return;
		}
		parent = player.parentNode;
		var full = player;
		while (full = full.parentNode) {
			if (full.getAttribute && full.nodeName != 'OBJECT') {
				full.setAttribute('full_stack', true);
				parentArray.push(full);
			}
			if (full.nodeName == 'HTML') {
				break;
			}
		}
		if (type == 'innerIframe') {
			full = iframe;
			do {
				if (full.getAttribute) {
					full.setAttribute('full_stack', true);
					parentArray.push(full);
				}
				if (full.nodeName == 'HTML') {
					break;
				}
			} while (full = full.parentNode);
		}
	}
	function checkObject(objectArray) {
		if (objectArray.length > 0) {
			for (i = 0; i < objectArray.length; i++) {
				console.log('object播放器检测' + i);
				if (objectArray[i].type == 'application/x-shockwave-flash' && objectArray[i].offsetWidth > 256 && objectArray[i].offsetHeight > 128) {
					player = objectArray[i];
					type = 'object';
					console.log('找到object播放器');
					break;
				}
			}
		}
	}
	function checkEmbed(embedArray) {
		if (embedArray.length > 0) {
			for (i = 0; i < embedArray.length; i++) {
				console.log('embed播放器检测' + i);
				if (embedArray[i].type == 'application/x-shockwave-flash' && embedArray[i].offsetWidth > 256 && embedArray[i].offsetHeight > 128) {
					player = embedArray[i];
					type = 'embed';
					console.log('找到embed播放器');
					break;
				}
			}
		}
	}
	function checkHtml5(html5Array) {
		if (html5Array.length > 0) {
			for (i = 0; i < html5Array.length; i++) {
				console.log('html5播放器检测' + i);
				if (html5Array[i].offsetWidth > 256 && html5Array[i].offsetHeight > 128) {
					player = html5Array[i];
					type = 'html5';
					console.log('找到html5播放器');
					break;
				}
			}
		}
	}
	function checkIframe(iframeArray) {
		if (iframeArray.length > 0) {
			for (var i = 0; i < iframeArray.length; i++) {
				if (iframeArray[i].offsetWidth > 256 && iframeArray[i].offsetHeight > 128) {
					try {
						var objectArray = iframeArray[i].contentWindow.document.getElementsByTagName('object');
						console.log('iframe' + i + '中object数量' + objectArray.length);
						checkObject(objectArray);
						if (!player) {
							console.log('iframe' + i + '中未找到object播放器');
							var embedArray = iframeArray[i].contentWindow.document.getElementsByTagName('embed');
							console.log('iframe' + i + '中embed数量' + embedArray.length);
							checkEmbed(embedArray);
						}
						if (player) {
							iframe = iframeArray[i];
							type = 'innerIframe';
							break;
						} else {
							console.log('未找到iframe' + i + '中的播放器');
						}
					} catch (e) {
						player = iframeArray[i];
						type = 'iframe';
						console.log('找到可能通过iframe跨域引用的播放器');
						break;
					}
				}
			}
		}
	}
	function fullWin() {
		if (!fullStatus) {
			window.addEventListener('resize', fullWin, false);
			playerStyle = player.style.cssText;
		}
		for (var i = 0; i < parentArray.length; i++) {
			if (!fullStatus) {
				backStyle[i] = parentArray[i].style.cssText;
			}
			parentArray[i].style.cssText = 'width:100% !important;height:100% !important;max-width:100% !important;margin:0px !important;padding:0px !important;top:0px !important;left:0px !important;z-index:2147483645 !important;overflow:hidden !important;position:fixed !important;background:#000 !important;';
		}
		player.style.cssText = 'width:calc(100% - 2px) !important;height:100% !important;z-index:2147483645 !important;left:1px !important;position:relative !important;visibility:visible !important;'
		console.log('网页全屏完成');
		fullStatus = true;
	}
	function smallWin() {
		window.removeEventListener('resize', fullWin, false);
		for (var i = 0; i < parentArray.length; i++) {
			parentArray[i].style.cssText = backStyle[i];
		}
		player.style.cssText = playerStyle;
		console.log('恢复完成');
		fullStatus = false;
	}
	init();
})();
// -AntiBlackEasyVideo- //
(function() {
	Function.prototype.bind = function() {
		var fn = this,
			arg = Array.prototype.slice.call(arguments),
			obj = arg.shift();
		return function() {
			return fn.apply(obj, arg.concat(Array.prototype.slice.call(arguments)));
		};
	};
	var EasyvideoSwfaccAntiadsblack = {
		host: [],
		list: [],
		done: [],
		rule: [{ // tudou_tudou //
			find: /^https?:\/\/js\.tudouui\.com\/.*\/Portalplayer_[\d]{3}\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/loader_td.swf'
		}, { // tudou_portal_fix //
			find: /^https?:\/\/js\.tudouui\.com\/.*\/Portalplayer_[\d]{2}\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_olc.swf' + '?tvcCode=-1&swfPath=' + 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_out.swf'
		}, { // tudou_out // _| GMscript in Firefox |_
			find: /^https?:\/\/(www\.)?tudou\.com\/.*(\/v\.swf)?/i,
			replace: function(el, find) {
				var isURL = /'firefox'/i.test(navigator.userAgent),
					player = el.data || el.src;
				GM_xmlhttpRequest({
					url: isURL ? player : 'http://noadsturl.y30.cn/noads-turl.php?' + encodeURIComponent(player),
					method: isURL ? 'HEAD' : 'GET',
					onload: function(response) {
						var url = isURL ? response.finalUrl : response.responseText;
						if (url) {
							url = url.replace(/https?:\/\/js\.tudouui\.com\/.*?\/olc_[^.]*?\.swf\?.*(iid=[\w]*)/i, this.host + 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_olc.swf' + '?tvcCode=-1' + '&$1');
							url = url.replace(/https?:\/\/js\.tudouui\.com\/.*?\/SocialPlayer_[^.]*?\.swf([^\/]+)tvcCode=-?.*/i, this.host + 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_out.swf' + '$1' + 'autoPlay=true');
							this.Reload.bind(this, el, find, url)();
						}
					}.bind(this)
				});
			}
		}, { // tudou_olc_fix //
			find: /^https?:\/\/js\.tudouui\.com\/bin\/.*player[^\.]*\/olc_[^.]*?\.swf.*\?(iid=\d+)?/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_out.swf' + '?tvcCode=-1&swfPath=' + 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_olc.swf' + '&$1'
		}, { // tudou_socialplayer_fix //
			find: /^https?:\/\/js\.tudouui\.com\/bin\/.*SocialPlayer_[^.]*?\.swf.*\?(iid=\d+)?/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_out.swf' + '?tvcCode=-1&swfPath=' + 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_sp.swf' + '&$1'
		}, { // tudou_olc_socialplayer //
			find: /^https?:\/\/js\.tudouui\.com\/bin\/.*player[^\.]*\/olc_[^.]*?\.swf|^https?:\/\/js\.tudouui\.com\/bin\/.*SocialPlayer_[^.]*?\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_out.swf'
		}, { // tudou_nplayer_1 //
			find: /^https?:\/\/dp\.tudou\.com\/.*nplayer[^.]*?\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_olc.swf' + '?tvcCode=-1&swfPath=' + 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_sp.swf'
		}, { // tudou_nplayer_2 //
			find: /^https?:\/\/js\.tudouui\.com\/.*\/nplayer[^.]*?\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_olc.swf' + '?tvcCode=-1&swfPath=' + 'https://qtxmd.googlecode.com/svn/swfplayer/tudou_sp.swf'
		}, { // iqiyi_definitionID //
			find: /^https?:\/\/(www|player|dispatcher)\.(video\.)?i?qiyi\.com\/.*player[^\.]*\.swf\?.*[\w&]ID=([^\/&]{32})/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/iqiyi_out.swf' + '?vid=$3'
		}, { // iqiyi_qiyi //
			find: /^https?:\/\/(www|player|dispatcher)\.(video|.*)\.i?qiyi\.com\/.*\/.*player[^\.]*\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/iqiyi.swf'
		}, { // iqiyi_iqiyi5 //
			find: /^https?:\/\/(www\.)?i?qiyi\.com\/(player\/\d+\/player|common\/flashplayer\/\d+\/(Enjon|Enjoy|Main|Share)?Player_[^.]*?)\.swf/i,
			replace: function(el, find) {
				var url = document.querySelector('span[data-flashplayerparam-flashurl]') ? 'https://qtxmd.googlecode.com/svn/swfplayer/iqiyi5.swf' : 'https://qtxmd.googlecode.com/svn/swfplayer/iqiyi.swf';
				this.Reload.bind(this, el, find, this.host + url)();
			}
		}, { // iqiyi_out //
			find: /^https?:\/\/(player|dispatcher)\.video\.i?qiyi\.com\/(.*[\?&].*id=)?([^\/&]{32}).*/i,
			replace: function(el, find) {
				var url = 'https://qtxmd.googlecode.com/svn/swfplayer/iqiyi_out.swf' + '?vid=$3',
					match = (el.data || el.src).match(/(tvId|autoplay)=[\d]+/ig);
				if (match)
					url += '&' + match.join('&');
				this.Reload.bind(this, el, find, this.host + url)();
			}
		}, { // iqiyi_out_qiyi //
			find: /^https?:\/\/(player|dispatcher)\.video\.i?qiyi\.com\/(i?qiyi|.*player[^\.]*\.swf)/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/iqiyi.swf'
		}, { // iqiyi_pps_flv //
			find: /^https?:\/\/(www\.)?i?qiyi\.com\/.*player\/\d+\/PPSMainPlayer_[^.]*?\.swf\?.*v=(\d+)/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/iqiyi_out.swf' + '?v=$2' + '&autoplay=true'
		}, { // iqiyi_pps //
			find: /^https?:\/\/(www\.)?i?qiyi\.com\/common\/flashplayer\/\d+\/PPSMainPlayer_[^.]*?\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/iqiyi.swf'
		}, { // iqiyi_duapp //
			find: /^https?:\/\/([^\.]*|[^\/]+)\.duapp\.com\/\w+\/(.*[\?&].*id=)?([^\/&]{32}).*\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/iqiyi.swf' + '?vid=$3'
		}, { // pptv //
			find: /^https?:\/\/player\.pplive\.cn\/ikan\/.*\/player4player2\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/pptv.swf'
		}, { // pplive //
			find: /^https?:\/\/player\.pplive\.cn\/live\/.*\/player4live2\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/pplive.swf'
		}, { // pptv_pplive_out // _| GMscript in Firefox |_
			find: /^https?:\/\/player\.pptv\.com\/v\/(.*\.swf)?/i,
			replace: function(el, find) {
				var isURL = /'firefox'/i.test(navigator.userAgent),
					player = el.data || el.src;
				GM_xmlhttpRequest({
					url: isURL ? player : 'http://noadsturl.y30.cn/noads-turl.php?' + encodeURIComponent(player),
					method: isURL ? 'HEAD' : 'GET',
					onload: function(response) {
						var url = isURL ? response.finalUrl : response.responseText;
						if (url) {
							url = url.replace(/https?:\/\/player\.pplive\.cn\/ikan\/.*\/player4player2\.swf/i, this.host + 'https://qtxmd.googlecode.com/svn/swfplayer/pptv.swf');
							url = url.replace(/https?:\/\/player\.pplive\.cn\/live\/.*\/player4live2\.swf/i, this.host + 'https://qtxmd.googlecode.com/svn/swfplayer/pplive.swf');
							this.Reload.bind(this, el, find, url)();
						}
					}.bind(this)
				});
			}
		}, { // sina_old-to-new_vid //
			find: /^https?:\/\/p\.you\.video\.sina\.com\.cn\/(player|swf)\/.*Player[^\.]*\.swf\?.*(vid|vids)=(\d+)/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/sina.swf' + '?as=0&vid=$3' + '&tHostName=you.video.sina.com.cn'
		}, { // sina_old-to-new_1 //
			find: /^https?:\/\/p\.you\.video\.sina\.com\.cn\/(player|swf)\/.*Player(2014|2013|2012|2011|2010)[^.]*?\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/sina.swf' + '?as=0' + '&tHostName=you.video.sina.com.cn'
		}, { // sina_old-to-new_2 //
			find: /^https?:\/\/p\.you\.video\.sina\.com\.cn\/(player|swf)\/(?!focus).*player\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/sina.swf' + '?as=0' + '&tHostName=you.video.sina.com.cn'
		}, { // sina_out-to-new_1 //
			find: /^https?:\/\/you\.video\.sina\.com\.cn\/.*\/outplayrefer\.php\/vid=(\d+)_.*\/s\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/sina.swf' + '?as=0&vid=$1' + '&tHostName=you.video.sina.com.cn'
		}, { // sina_out-to-new_2 //
			find: /^https?:\/\/vhead\.blog\.sina\.com\.cn\/player\/outer_player\.swf\?.*vid=(\d+)/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/sina.swf' + '?as=0&vid=$1' + '&tHostName=you.video.sina.com.cn'
		}, { // sina_out-to-new_3 //
			find: /^https?:\/\/video\.sina\.com\.cn\/.*\/outPlayRefer\.php\/vid=(\d+)\/.*\/s\.swf/i,
			replace: 'https://qtxmd.googlecode.com/svn/swfplayer/sina.swf' + '?as=0&vid=$1' + '&tHostName=you.video.sina.com.cn'
		}, { // sina_out-to-new_sinawebApi // _| GMscript in Firefox |_
			find: /^https?:\/\/you\.video\.sina\.com\.cn\/api\/sinawebApi\/outplay\.php\/.*([^\/]+\.swf)?/i,
			replace: function(el, find) {
				var isURL = /'firefox'/i.test(navigator.userAgent),
					player = el.data || el.src;
				GM_xmlhttpRequest({
					url: isURL ? player : 'http://noadsturl.y30.cn/noads-turl.php?' + encodeURIComponent(player),
					method: isURL ? 'HEAD' : 'GET',
					onload: function(response) {
						var url = isURL ? response.finalUrl : response.responseText;
						if (url) {
							url = url.replace(/https?:\/\/p\.you\.video\.sina\.com\.cn\/swf\/quotePlayer([\d]{8})_V([\w]{9})\.swf\?.*(&vid=\d+&)-?.*/i, this.host + 'https://qtxmd.googlecode.com/svn/swfplayer/sina.swf' + '?as=0&actlogActive=1' + '$3' + 'autoPlay=true' + '&tHostName=you.video.sina.com.cn');
							this.Reload.bind(this, el, find, url)();
						}
					}.bind(this)
				});
			}
		}, { // TencentPlayer_to_fix
			find: /^https?:\/\/mat1\.qq\.com\/news\/act3\/js\/QQPlayer[^.]*?\.swf/i,
			replace: 'http://static.video.qq.com/TencentPlayer.swf'
		}, { // TencentPlayer_to_new
			find: /^https?:\/\/cache\.tv\.qq\.com\/QQPlayer[^.]*?\.swf/i,
			replace: 'http://static.video.qq.com/TencentPlayer.swf'
		}],
		style: 'object,embed{-webkit-animation-duration:.001s;-webkit-animation-name:playerInserted;-ms-animation-duration:.001s;-ms-animation-name:playerInserted;-o-animation-duration:.001s;-o-animation-name:playerInserted;animation-duration:.001s;animation-name:playerInserted;}@-webkit-keyframes playerInserted{from{opacity:0.99;}to{opacity:1;}}@-ms-keyframes playerInserted{from{opacity:0.99;}to{opacity:1;}}@-o-keyframes playerInserted{from{opacity:0.99;}to{opacity:1;}}@keyframes playerInserted{from{opacity:0.99;}to{opacity:1;}}',
		Handler: function(e) {
			if (e.animationName != 'playerInserted')
				return;
			var el = e.target;
			if (this.done.indexOf(el) != -1)
				return;
			this.done.push(el);
			var player = el.data || el.src;
			if (!player)
				return;
			for (var i in this.rule) {
				var find = this.rule[i]['find'];
				if (find.test(player)) {
					var replace = this.rule[i]['replace'];
					typeof replace == 'function' ? this.list.push(replace.bind(this, el, find)) : this.Reload.bind(this, el, find, this.host + replace)();
				}
			}
		},
		Reload: function(el, find, replace) {
			el.data && (el.data = el.data.replace(find, replace)) || el.src && ((el.src = el.src.replace(find, replace)) && (el.style.display = 'block'));
			var next = el.nextSibling,
				node = el.parentNode,
				elem = el.cloneNode(true);
			this.done.push(elem);
			if (node) {
				node.removeChild(el);
				next ? node.insertBefore(elem, next) : node.appendChild(elem);
			}
		},
		Style: function(css) {
			var style = document.createElement('style');
			style.setAttribute('type', 'text/css');
			style.innerHTML = css || this.style;
			document.getElementsByTagName('head')[0].appendChild(style);
		},
		Timer: function() {
			setInterval(function() {
				this.list.length && this.list.shift()();
			}.bind(this), 100);
		},
		Init: function() {
			var events = ['webkitAnimationStart', 'msAnimationStart', 'oAnimationStart', 'animationstart'];
			for (var i in events)
				document.addEventListener(events[i], this.Handler.bind(this), false);
			this.Style();
			this.Timer();
		}
	};
	EasyvideoSwfaccAntiadsblack.Init();
})();
